
local var daily_increase 

use "../2_Data/temp/data_selected_region.dta", clear

local trends trend_prov1 trend_prov3 trend_prov5 trend_prov8 trend_prov10 trend_prov11 trend_prov12 trend_prov14 trend_prov16 trend_prov18 trend_prov19

levelsof codice_regione, local(prov)


	matrix B = [.]
		matrix CIL = [.]
		matrix CIU = [.]
		matrix DATE = [.]

	
		
forvalues i = 30/38 {
    cap drop post post_election	trend*
    gen post = (week>=`i')
	gen post_election = election*post
    eststo clear
gen trend = (week-`i')*(post-1)
	
	foreach province in `prov' {
    
	gen trend_prov`province'= (codice_regione==`province')*trend
}

eststo: reg2hdfespatial `var' post_election `trends', lat(x_region) lon(y_region) timevar(time_fe_region) panelvar(region_code) distcutoff(1300) lagcutoff(110)

			estout est1, cells(b se)

matrix help = r(coefs)

matrix B = [B,help[1,1]]
matrix CIL = [CIL,help[1,1]-help[1,2]*1.96]
matrix CIU = [CIU,help[1,1]+help[1,2]*1.96]
			matrix DATE = [DATE, `i']
			
}

		matrix M = [B \ CIL \ CIU \ DATE ]'
		svmat M
		replace M1 = . if M2 == 0 & M3 == 0
		replace M2 = . if M1 == .
		replace M3 = . if M1 == .
			

tw (line M1 M4, lcolor(black) lwidth(medthick)) (line M2 M4, lcolor(gs10)  lpattern(dash)) ///
		       (line M3 M4, lcolor(gs10) lpattern(dash)) (function y = 0 * x, range(M4) lcolor(red)),  scheme(s1mono)  ///
			   graphregion(color(white)) bgcolor(white) xtitle("Week of campaign start", size(large)) ///
			   legend(order(1 2) label(1 "Estimated coefficients") label(2 "95% confidence intervals") cols(1) region(lcolor(white)) just(left) position(7) ring(0) bplacement(sw)) ///  
			   xlabel(30(1)38, labsize(large) valuelabel) ylabel(-0.1 "-0.1" 0 "0" 0.1 "0.10" 0.2 "0.20" 0.3 "0.30", labsize(large) angle(0)) 

local figure "_`var'_camstart_boundary"
			   


local var tamponi_day 

use "../2_Data/temp/data_selected_region.dta", clear

local trends trend_prov1 trend_prov3 trend_prov5 trend_prov8 trend_prov10 trend_prov11 trend_prov12 trend_prov14 trend_prov16 trend_prov18 trend_prov19

levelsof codice_regione, local(prov)


	matrix B = [.]
		matrix CIL = [.]
		matrix CIU = [.]
		matrix DATE = [.]

	
		
forvalues i = 30/38 {
    cap drop post post_election	trend*
    gen post = (week>=`i')
	gen post_election = election*post
    eststo clear
gen trend = (week-`i')*(post-1)
	
	foreach province in `prov' {
    
	gen trend_prov`province'= (codice_regione==`province')*trend
}

eststo: reg2hdfespatial `var' post_election `trends', lat(x_region) lon(y_region) timevar(time_fe_region) panelvar(region_code) distcutoff(1300) lagcutoff(110)

			estout est1, cells(b se)

matrix help = r(coefs)

matrix B = [B,help[1,1]]
matrix CIL = [CIL,help[1,1]-help[1,2]*1.96]
matrix CIU = [CIU,help[1,1]+help[1,2]*1.96]
			matrix DATE = [DATE, `i']
			
}

		matrix M = [B \ CIL \ CIU \ DATE ]'
		svmat M
		replace M1 = . if M2 == 0 & M3 == 0
		replace M2 = . if M1 == .
		replace M3 = . if M1 == .
			

tw (line M1 M4, lcolor(black) lwidth(medthick)) (line M2 M4, lcolor(gs10)  lpattern(dash)) ///
		       (line M3 M4, lcolor(gs10) lpattern(dash)) (function y = 0 * x, range(M4) lcolor(red)),  scheme(s1mono)  ///
			   graphregion(color(white)) bgcolor(white) xtitle("Week of campaign start", size(large)) ///
			   legend(order(1 2) label(1 "Estimated coefficients") label(2 "95% confidence intervals") cols(1) region(lcolor(white)) just(left) position(7) ring(0) bplacement(sw)) ///  
			   xlabel(30(1)38, labsize(large) valuelabel) ylabel(-0.30 "-0.30" -0.2 "-0.20" -0.10 "-0.10" 0 "0" 0.1 "0.10", labsize(large) angle(0)) 

local figure "_`var'_camstart_boundary"


local var ratio2 

use "../2_Data/temp/data_selected_region.dta", clear

local trends trend_prov1 trend_prov3 trend_prov5 trend_prov8 trend_prov10 trend_prov11 trend_prov12 trend_prov14 trend_prov16 trend_prov18 trend_prov19

levelsof codice_regione, local(prov)


	matrix B = [.]
		matrix CIL = [.]
		matrix CIU = [.]
		matrix DATE = [.]

	
		
forvalues i = 30/38 {
    cap drop post post_election	trend*
    gen post = (week>=`i')
	gen post_election = election*post
    eststo clear
gen trend = (week-`i')*(post-1)
	
	foreach province in `prov' {
    
	gen trend_prov`province'= (codice_regione==`province')*trend
}

eststo: reg2hdfespatial `var' post_election `trends', lat(x_region) lon(y_region) timevar(time_fe_region) panelvar(region_code) distcutoff(1300) lagcutoff(110)

			estout est1, cells(b se)

matrix help = r(coefs)

matrix B = [B,help[1,1]]
matrix CIL = [CIL,help[1,1]-help[1,2]*1.96]
matrix CIU = [CIU,help[1,1]+help[1,2]*1.96]
			matrix DATE = [DATE, `i']
			
}

		matrix M = [B \ CIL \ CIU \ DATE ]'
		svmat M
		replace M1 = . if M2 == 0 & M3 == 0
		replace M2 = . if M1 == .
		replace M3 = . if M1 == .
			

tw (line M1 M4, lcolor(black) lwidth(medthick)) (line M2 M4, lcolor(gs10)  lpattern(dash)) ///
		       (line M3 M4, lcolor(gs10) lpattern(dash)) (function y = 0 * x, range(M4) lcolor(red)),  scheme(s1mono)  ///
			   graphregion(color(white)) bgcolor(white) xtitle("Week of campaign start", size(large)) ///
			   legend(order(1 2) label(1 "Estimated coefficients") label(2 "95% confidence intervals") cols(1) region(lcolor(white)) just(left) position(7) ring(0) bplacement(sw)) ///  
			   xlabel(30(1)38, labsize(large) valuelabel) ylabel(-0.2 "-0.20" 0 "0" 0.2 "0.20" 0.4 "0.40" 0.6 "0.60", labsize(large) angle(0)) 

local figure "_`var'_camstart_boundary"


local var totale_osp 

use "../2_Data/temp/data_selected_region.dta", clear

local trends trend_prov1 trend_prov3 trend_prov5 trend_prov8 trend_prov10 trend_prov11 trend_prov12 trend_prov14 trend_prov16 trend_prov18 trend_prov19

levelsof codice_regione, local(prov)

	matrix B = [.]
		matrix CIL = [.]
		matrix CIU = [.]
		matrix DATE = [.]

	
		
forvalues i = 30/38 {
    cap drop post post_election	trend*
    gen post = (week>=`i')
	gen post_election = election*post
    eststo clear
	gen trend = (week-`i')*(post-1)
	
	foreach province in `prov' {
    
	gen trend_prov`province'= (codice_regione==`province')*trend
}

eststo: reg2hdfespatial `var' post_election `trends', lat(x_region) lon(y_region) timevar(time_fe_region) panelvar(region_code) distcutoff(1300) lagcutoff(110)

			estout est1, cells(b se)

matrix help = r(coefs)

matrix B = [B,help[1,1]]
matrix CIL = [CIL,help[1,1]-help[1,2]*1.96]
matrix CIU = [CIU,help[1,1]+help[1,2]*1.96]
			matrix DATE = [DATE, `i']
			
}

		matrix M = [B \ CIL \ CIU \ DATE ]'
		svmat M
		replace M1 = . if M2 == 0 & M3 == 0
		replace M2 = . if M1 == .
		replace M3 = . if M1 == .
			

tw (line M1 M4, lcolor(black) lwidth(medthick)) (line M2 M4, lcolor(gs10)  lpattern(dash)) ///
		       (line M3 M4, lcolor(gs10) lpattern(dash)) (function y = 0 * x, range(M4) lcolor(red)),  scheme(s1mono)  ///
			   graphregion(color(white)) bgcolor(white) xtitle("Week of campaign start", size(large)) ///
			   legend(order(1 2) label(1 "Estimated coefficients") label(2 "95% confidence intervals") cols(1) region(lcolor(white)) just(left) position(7) ring(0) bplacement(sw)) ///  
			   xlabel(30(1)38, labsize(large) valuelabel) ylabel(-0.15 "-0.15" 0 "0" 0.15 "0.15" 0.3 "0.30" 0.45 "0.45", labsize(large) angle(0)) 

local figure "_`var'_camstart_boundary"
			   


local var terapia 

use "../2_Data/temp/data_selected_region.dta", clear

local trends trend_prov1 trend_prov3 trend_prov5 trend_prov8 trend_prov10 trend_prov11 trend_prov12 trend_prov14 trend_prov16 trend_prov18 trend_prov19

levelsof codice_regione, local(prov)


	matrix B = [.]
		matrix CIL = [.]
		matrix CIU = [.]
		matrix DATE = [.]

	
		
forvalues i = 30/38 {
    cap drop post post_election	trend*
    gen post = (week>=`i')
	gen post_election = election*post
    eststo clear
	gen trend = (week-`i')*(post-1)
	
	foreach province in `prov' {
    
	gen trend_prov`province'= (codice_regione==`province')*trend
}

eststo: reg2hdfespatial `var' post_election `trends', lat(x_region) lon(y_region) timevar(time_fe_region) panelvar(region_code) distcutoff(1300) lagcutoff(110)

			estout est1, cells(b se)

matrix help = r(coefs)

matrix B = [B,help[1,1]]
matrix CIL = [CIL,help[1,1]-help[1,2]*1.96]
matrix CIU = [CIU,help[1,1]+help[1,2]*1.96]
			matrix DATE = [DATE, `i']
			
}

		matrix M = [B \ CIL \ CIU \ DATE ]'
		svmat M
		replace M1 = . if M2 == 0 & M3 == 0
		replace M2 = . if M1 == .
		replace M3 = . if M1 == .
			

tw (line M1 M4, lcolor(black) lwidth(medthick)) (line M2 M4, lcolor(gs10)  lpattern(dash)) ///
		       (line M3 M4, lcolor(gs10) lpattern(dash)) (function y = 0 * x, range(M4) lcolor(red)),  scheme(s1mono)  ///
			   graphregion(color(white)) bgcolor(white) xtitle("Week of campaign start", size(large)) ///
			   legend(order(1 2) label(1 "Estimated coefficients") label(2 "95% confidence intervals") cols(1) region(lcolor(white)) just(left) position(7) ring(0) bplacement(sw)) ///  
			   xlabel(30(1)38, labsize(large) valuelabel) ylabel(-0.05 "-0.05" 0 "0" 0.05 "0.05" 0.1 "0.10" 0.15 "0.15", labsize(large) angle(0)) 

local figure "_`var'_camstart_boundary"


local var deceduti_day 

use "../2_Data/temp/data_selected_region.dta", clear

local trends trend_prov1 trend_prov3 trend_prov5 trend_prov8 trend_prov10 trend_prov11 trend_prov12 trend_prov14 trend_prov16 trend_prov18 trend_prov19

levelsof codice_regione, local(prov)



	matrix B = [.]
		matrix CIL = [.]
		matrix CIU = [.]
		matrix DATE = [.]

	
		
forvalues i = 30/38 {
    cap drop post post_election	trend*
    gen post = (week>=`i')
	gen post_election = election*post
    eststo clear
	gen trend = (week-`i')*(post-1)
	
	foreach province in `prov' {
    
	gen trend_prov`province'= (codice_regione==`province')*trend
}

eststo: reg2hdfespatial `var' post_election `trends', lat(x_region) lon(y_region) timevar(time_fe_region) panelvar(region_code) distcutoff(1300) lagcutoff(110)

			estout est1, cells(b se)

matrix help = r(coefs)

matrix B = [B,help[1,1]]
matrix CIL = [CIL,help[1,1]-help[1,2]*1.96]
matrix CIU = [CIU,help[1,1]+help[1,2]*1.96]
			matrix DATE = [DATE, `i']
			
}

		matrix M = [B \ CIL \ CIU \ DATE ]'
		svmat M
		replace M1 = . if M2 == 0 & M3 == 0
		replace M2 = . if M1 == .
		replace M3 = . if M1 == .
			

tw (line M1 M4, lcolor(black) lwidth(medthick)) (line M2 M4, lcolor(gs10)  lpattern(dash)) ///
		       (line M3 M4, lcolor(gs10) lpattern(dash)) (function y = 0 * x, range(M4) lcolor(red)),  scheme(s1mono)  ///
			   graphregion(color(white)) bgcolor(white) xtitle("Week of campaign start", size(large)) ///
			   legend(order(1 2) label(1 "Estimated coefficients") label(2 "95% confidence intervals") cols(1) region(lcolor(white)) just(left) position(7) ring(0) bplacement(sw)) ///  
			   xlabel(30(1)38, labsize(large) valuelabel) ylabel(-0.01 "-0.01" 0 "0" 0.01 "0.01" 0.02 "0.02" 0.03 "0.03", labsize(large) angle(0)) 

local figure "_`var'_camstart_boundary"


